<%@page import="multiface.awwadco.jpa.Prodotto"%>
<%@page import="multiface.awwadco.jpa.PersistenceManager"%>
<%@page import="javax.persistence.EntityManagerFactory"%>
<%@page import="javax.persistence.EntityManager"%>
<%@page import="java.util.List"%>
<%@page import="multiface.awwadco.jpa.File"%>
<%
    EntityManagerFactory emf = PersistenceManager.getInstance().getEntityManagerFactory();
    EntityManager em = emf.createEntityManager();

    Prodotto p = em.find(Prodotto.class, Integer.parseInt(request.getParameter("pid")));

    List<File> lf = p.getFileList();
    for (int i = 0; i < 4; i++) {
        if (i < lf.size()) {
            File f = lf.get(i);
            out.print("<img onmouseover=\"over_image_set("+p.getIdprodotto()+")\" src=\"GetImageServlet?th=y&fid=" + f.getIdfile() + "\"></img>");
        } else {
            out.print("<img onmouseover=\"over_image_set("+p.getIdprodotto()+")\" src=\"engine/img/notImage.png\"></img>");
        }
    }
%>